package ge.devfest.hackathon.gg;

import ge.devfest.hackathon.gg.model.Activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

import android.annotation.SuppressLint;
import android.app.Application;

public class GuerrillaApplication extends Application {

	private static GuerrillaApplication sInstance;
	private HashMap<Integer, Activity> mActivityCache = new HashMap<Integer, Activity>();
	
	@SuppressLint("UseSparseArrays")
	@Override
	public void onCreate() {
		super.onCreate();
		sInstance = this;
	}
	
	public static GuerrillaApplication getInstance() {
		return sInstance;
	}
	
	public void putActivity(int id, Activity activity) {
		mActivityCache.put(id, activity);
	}
	
	public Activity getActivity(int id) {
		return mActivityCache.get(id);
	}
	
	public void clearActivityCache() {
		mActivityCache.clear();
	}
	
	public List<Activity> list() {
		List<Activity> activityes = new ArrayList<Activity>();
		Set<Integer> keySet = mActivityCache.keySet();
		for (Integer i : keySet) {
			activityes.add(mActivityCache.get(i));
		}
		return activityes;
	}
	
}
